package com.macro.mall.exception;

import com.macro.mall.constans.RespConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.http.HttpStatus;

@Data
@EqualsAndHashCode(callSuper = false)
public class BaseException extends RuntimeException {
    private HttpStatus status;
    private String errorCode;
    private String errorMessage;
    private transient Object data;

    public BaseException() {
        this.status = HttpStatus.BAD_REQUEST;
        this.errorCode = null;
        this.errorMessage = null;
        this.data = null;
    }

    public BaseException(String errorMessage) {
        super(errorMessage);
        this.status = HttpStatus.BAD_REQUEST;
        this.errorMessage = errorMessage;
        this.data = null;
        this.errorCode = RespConstants.FAILURE;
    }

    public BaseException(HttpStatus status, String errorMessage) {
        super(errorMessage);
        this.status = status;
        this.errorMessage = errorMessage;
        this.data = null;
        this.errorCode = null;
    }

    public BaseException(String errorCode, String errorMessage) {
        super(errorMessage);
        this.status = HttpStatus.BAD_REQUEST;
        this.errorMessage = errorMessage;
        this.data = null;
        this.errorCode = errorCode;
    }

    public BaseException(HttpStatus status, String errorMessage, Object data) {
        super(errorMessage);
        this.status = status;
        this.errorMessage = errorMessage;
        this.data = data;
        this.errorCode = null;
    }

    public BaseException(HttpStatus status, String errorCode, String errorMessage) {
        super(errorMessage);
        this.status = status;
        this.errorMessage = errorMessage;
        this.data = null;
        this.errorCode = errorCode;
    }

    public BaseException(HttpStatus status, String errorCode, String errorMessage, Object data) {
        super(errorMessage);
        this.status = status;
        this.errorMessage = errorMessage;
        this.data = data;
        this.errorCode = errorCode;
    }

    public BaseException(String errorCode, String errorMessage, Object data) {
        super(errorMessage);
        this.status = HttpStatus.BAD_REQUEST;
        this.errorMessage = errorMessage;
        this.data = data;
        this.errorCode = errorCode;
    }
}